package lt.laimis.shop.service.node;

import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.WebServiceFactory;
import org.alfresco.webservice.types.*;
import org.alfresco.webservice.repository.QueryResult;
import org.alfresco.webservice.authentication.AuthenticationFault;
import org.alfresco.webservice.authentication.AuthenticationServiceLocator;

import java.util.List;
import java.util.ArrayList;
import java.rmi.RemoteException;

import lt.laimis.shop.dao.DaoNode;
import net.sourceforge.stripes.integration.spring.SpringBean;

/**
 * Created by IntelliJ IDEA.
 * User: laimis
 * Date: Jul 15, 2008
 * Time: 11:20:39 PM
 * To change this template use File | Settings | File Templates.
 */
public class NodeService {
    private List<Node> nodeList;
    protected DaoNode daoNode;

    public void setDaoNode(DaoNode daoNode) {
        this.daoNode = daoNode;
    }

    public List<Node> getNodeList() {
        if(nodeList == null){
           this.nodeList = daoNode.getListNode();
        }
        return nodeList;
    }                     

    private String nodeQName;

    public List<Node> getNodesByParentId(String parentId) {
        List<Node> childrens = new ArrayList<Node>();
        if(parentId != null && getNodeList() != null){
                for(Node node : this.nodeList){
                     if(node.getParentId().equals(parentId)){
                           childrens.add(node);
                     }
                }
        }
        return childrens;
    }

    public String getNodeQName() {
        return nodeQName;
    }

    public void setNodeQName(String nodeQName) {
        this.nodeQName = nodeQName;
    }

}

